package com.trkj.property_controller;

import com.trkj.entity.BuildingEntity;
import com.trkj.service.BuildingService;
import com.trkj.vo.AjaxResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@CrossOrigin
public class BuildingController {
    @Autowired
    private BuildingService buildingService;
    @PostMapping("/selectBuilding")
    public List<BuildingEntity> selectBuilding(@RequestBody BuildingEntity buildingEntity){
        return buildingService.selectBuilding(buildingEntity);
    }
    @PostMapping("/AddBuild")
    public Boolean AddBuild(@RequestBody BuildingEntity buildingEntity){
        return buildingService.AddBuild(buildingEntity);
    }
    @PutMapping("/UpdateBuild")
    public Boolean UpdateBuild(@RequestBody BuildingEntity buildingEntity){
        log.info("修改楼宇信息:{}"+buildingEntity);
        return buildingService.UpdateBuild(buildingEntity);
    }
    @DeleteMapping("/deleteBuild")
    public Boolean deleteBuild(@RequestParam("id") int id){
        log.info("删除楼宇信息:{}"+id);
        return buildingService.deleteBuild(id);
    }
    //查询所有栋数
    @PostMapping("/BuildingList")
    public AjaxResponse BuildingList(){
        return AjaxResponse.success(buildingService.BuildingList());
    }
}
